#ifndef TCPCLIENT_H
#define TCPCLIENT_H

#include <QTextCodec>
#include <QWidget>

#include<QTcpSocket>
#include <QTimer>
#include "Task.h"
class TCPClient : public QObject
{
    Q_OBJECT
public:
    TCPClient();
    Task & getTask();
    static quint16 CRC16_chart(uchar *puchMsg, unsigned short usDataLen);
    Task mTask;
private:
    QTcpSocket *mTCPSocket=nullptr;
    QString ip="";
    int port;
    bool connectNet();

    QTimer *receiveTimer=nullptr;//回复定时器
    void receiveTimeout();
    int receiveWaitM=50;

    QTextCodec *codec=QTextCodec::codecForName("GBK");

public slots:
    void init();
    void startLanding(QString phone,QString pass,QString ip,QString port);
    void disConnectServer();
    void handleReadyRead();
    void write(QString str);
signals:
    void connectStatus(QString str);
};

#endif // TCPCLIENT_H
